#ifndef NANOCALIB_H
#define NANOCALIB_H


#include <QMainWindow>
#include <QWidget>
#include <QCheckBox>
#include <QSlider>
#include <QKeyEvent>
#include <QComboBox>
#include <QPushButton>
#include <QMessageBox>
#include <QTimer>

#include<opencv/cv.h>
#include<opencv/highgui.h>

#include "src/VideoWidget.h"
#include "src/Joystick.h"
#include "src/ControlThread.h"
#include "src/OptWidget.h"
#include "src/OmniWidget.h"
#include "src/CaptureThread.h"


namespace Ui {
    class nanoCalib;
}

/** \brief Main class file for the application

  This class acts as the main widget for the application window. It calls child widgets for video capture, joystick input, and commanding the manipulator.
*/

class nanoCalib : public QMainWindow
{
    Q_OBJECT

private:

    /** video window */
    QWidget *videoWindow;

    /**  videowidget which does the actual job of capturing from the camera */
    VideoWidget *cam;

    /** capture thread which uses libdc1394 functions to capture from camera */
    CaptureThread *captureThread;

    /** pointed to space explorer */
    Joystick *joystick;
    /** timer to poll space explorer */
    QTimer *joystickTimer;

    /** flag to set checkbox for video recording */
    QCheckBox *recState;

    /** pointer to manipulator command thread. This thread sends implements step planning algorithm and sends command to the manipulator */
    ControlThread *cThread;

    /** pointer to options window widget */
    ManipulatorOpts *mOpts;

    /** pointer to Phantom Omni widget */
    OmniWidget *omni;
    /** timer to poll Phantom Omni */
    QTimer *omniTimer;

    /** checkbox to select Space Explorer as input device */
    QCheckBox *joystickBox;
    /** checkbox to select Phantom Omni as the input device*/
    QCheckBox *omniBox;

    /** checkbox to select free mode */
    QCheckBox *freeMode;
    /** checkbox to select experiment mode*/
    QCheckBox *expMode;

    /** checkbox to select XY plane */
    QCheckBox *xyPlane;
    /** checkbox to select XZ plane*/
    QCheckBox *xzPlane;

    /** Combobox to select model to be used */
     QComboBox *selectModel;

     /** Combobox to select opeartor mode */
     QComboBox *operatorMode;

     /** Combobox to select joint update mode */
     QComboBox *jointUpdateMode;


public:
    explicit nanoCalib(QWidget *parent = 0); /**< Constructor */
    ~nanoCalib();
    void keyPressEvent(QKeyEvent *); /**< Qt Keypress event */

private:
    Ui::nanoCalib *ui;

public slots:
    void startExp(); /**< slot to start experiemnt. Is called when start button is pressed */
    void stopExp(); /**< slot to stop experiemnt. Is called when stop button is pressed */
    void close(); /**< slot to close application. Doesn't work properly*/

    void setMode(); /**< sets experiment mode based on checkbox selected */
    void setExpPlane(); /**< selects the vertical or horizontal plane for experiments */
    void setBlobDetect(int); /**< activate blob detection */

};

#endif // NANOCALIB_H
